# Maintainer: Muflone http://www.muflone.com/contacts/english/
# Contributor: Ordoban <dirk.langer@vvovgonik.de>

pkgname=perl-cpanel-json-xs
_perl_namespace=Cpanel
_perl_module=JSON-XS
pkgver=4.37
pkgrel=2
pkgdesc="cPanel fork of JSON::XS, fast and correct serializing"
arch=('loong64' 'x86_64')
license=('PerlArtistic' 'GPL')
depends=('perl')
url="https://metacpan.org/dist/${_perl_namespace}-${_perl_module}"
source=("https://cpan.metacpan.org/authors/id/R/RU/RURBAN/${_perl_namespace}-${_perl_module}-${pkgver}.tar.gz")
sha512sums=('f1b5fc161711815f33b3e05a19111d9c94ef817c952eb3d317cb8bc3fd973acdb645a6b129cb21345dccf4a161de069f0ab2d3cb807e7f6b20ebe2527ef48978')

build() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps
  perl Makefile.PL
  make
}

check() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  export PERL_MM_USE_DEFAULT=1
  make test
}

package() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  make pure_install INSTALLDIRS=vendor DESTDIR="${pkgdir}"
  # Delete unuseful files
  find "${pkgdir}" -name '.packlist' -delete
}
